<?php
namespace app\admin\middleware;
use think\facade\Cache;
class Check{
    public function handle($request, \Closure $next)
    {

        $admin_token = $request->param('admin_token/s','');
        if(empty($admin_token)){
            return error('未登录',100);
        }
        $admin_info = Cache::get('admin_token_'.$admin_token);
        
        if(empty($admin_info)){
            return error('已掉线，请重新登录',100);
        }
        $request->firm_id = $admin_info['firm_id'];
        $request->account_id = $admin_info['account_id'];
        $request->role = $admin_info['role'];
        return $next($request);
    }
}